#include <bits/stdc++.h>
#define mid ((l + r) >> 1)
using namespace std;

char buf[(int)2e7], *fs = buf;

inline int gn() { 
    int k = 0;
    char c = *fs++;
    for (; !isdigit(c); c = *fs++);
    for (; isdigit(c); c = *fs++) k = k * 10 + c - '0';
    return k;
}

struct node { 
    int sum;
    bool tg;
    node *ls, *rs;
    node() { 
        tg = 0, sum = 0;
        ls = rs = NULL;
    }
} *root;

node *build(int l, int r) { 
    node *x = new node();
    if (l == r) { 
        x->sum = gn();
        return x;
    }
    x->ls = build(l, mid);
    x->rs = build(mid + 1, r);
    x->sum = x->ls->sum + x->rs->sum;
    return x;
}

void change(node *x, int l, int r) { 
    if (x->tg) return;
    if (l == r) { 
        x->sum = sqrt(x->sum);
        if (x->sum == 1) x->tg = 1;
        return;
    }
    change(x->ls, l, mid);
    change(x->rs, mid + 1, r);
    x->sum = x->ls->sum + x->rs->sum;
    x->tg = x->ls->tg & x->rs->tg;
}

int query(node *x, int l, int r, int s, int t) { 
    if (l == s and r == t) 
        return x->sum;
    if (t <= mid) return query(x->ls, l, mid, s, t);
    if (s > mid) return query(x->rs, mid + 1, r, s, t);
    return query(x->ls, l, mid, s, mid) + query(x->rs, mid + 1, r, mid + 1, t);
}

int main() { 
    fread(buf, 1, (int)2e7, stdin);
    int n = gn();
    root = build(1, n);
    int m = gn();
    for (int i = 1, op, l, r; i <= m; i++) { 
        op = gn(), l = gn(), r = gn();
        if (!op) { 
            change(root, l, r);
        } else { 
            cout << query(root, 1, n, l, r) << '\n';
        }
    }
}
